mod _trait;
pub use _trait::_trait::Summary;
pub struct NewsArticle {
    pub headline: String,
    pub location: String,
    pub author: String,
    pub content: String,
}
impl Summary for NewsArticle {
    fn summarize(&self) -> String {
        format!("{},by {} ({})", self.headline, self.author, self.author)
    }
    fn default_summarize(&self) -> String {
        format!("默认实现取消")
    }
}
pub struct Tweet {
    pub username: String,
    pub content: String,
    pub reply: bool,
    pub retweet: bool,
}
impl Summary for Tweet {
    fn summarize(&self) -> String {
        format!("{}:{}", self.username, self.content)
    }
}
pub fn notify(item: impl Summary) {
    println!("{:?}{{{{p}}}}", item.default_summarize())
}
fn main() {
    let tweet = Tweet {
        username: String::from("horse_ebooks"),
        content: String::from("of course, as you probably already know, people"),
        reply: false,
        retweet: false,
    };
    let article = NewsArticle {
        headline: String::from("Penguins win the Stanley Cup Championship!"),
        location: String::from("Pittsburgh, PA, USA"),
        author: String::from("Iceburgh"),
        content: String::from(
            "The Pittsburgh Penguins once again are the best
    hockey team in the NHL.",
        ),
    };
    println!("New article available! {}", article.default_summarize());
    println!(
        "1 new tweet: {},{}",
        tweet.summarize(),
        tweet.default_summarize()
    );
    notify(tweet);
}
